<template>
  <el-dialog
    title="新增工单"
    :visible="visible"
    width="30%"
    :before-close="close"
  >
    <template>
      <el-form label-width="80px" :model="addform" :rules="rules" ref="addform">
        <el-form-item label="设备编号" prop="innerCode">
          <el-input v-model="addform.innerCode"></el-input>
        </el-form-item>
        <el-form-item label="工单类型" prop="taskStatus">
          <template>
            <my-input></my-input>
          </template>
        </el-form-item>
        <el-form-item label="补货数量">
          <el-button>补货清单 </el-button>
        </el-form-item>
        <el-form-item label="运营人员" prop="userName">
          <el-input v-model="addform.userName"></el-input>
        </el-form-item>
        <el-form-item label="备注" prop="desc">
          <el-input v-model="addform.desc" type="textarea"></el-input>
        </el-form-item>
      </el-form>
    </template>
    <span slot="footer" class="dialog-footer">
      <el-button @click="close">取 消</el-button>
      <el-button type="primary" @click="submit">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import MyInput from '@/components/MyInput.vue'
import { postTaskListApi } from '@/api/yunying'

export default {
  name: 'LikedeAddForm',
  components: { MyInput },
  props: {
    visible: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      addform: {},
      rules: {
        innerCode: [{ required: true, message: '请输入', trigger: 'blur' }],
        userName: [{ required: true, message: '请输入', trigger: 'blur' }],
        desc: [{ required: true, message: '请输入', trigger: 'blur' }],
        typeName: [{ required: true }]
      },
      list: []
    }
  },

  mounted () {},

  methods: {
    close () {
      this.$emit('update:visible', false)
    },
    async submit () {
      await this.$refs.addform.validate()
      const res = await postTaskListApi({
        ...this.addform,
        createType: 1,
        userId: null,
        details: {},
        productType: this.addform.taskStatus
      })
      console.log(res)
    }
  }
}
</script>

<style lang="scss" scoped></style>
